<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#" lang="en" xml:lang="en" dir="ltr">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 </head>
<?php 
$host = "localhost";
$user = "root"; 
$passwd = "1234"; 
$dbname = "book_db";
mysql_connect($host,$user,$passwd) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die("ติดต่อฐานข้อมูลไม่ได้");

//*** Add ***//
$sql = "INSERT INTO member ";
$sql .= "(MemName, MemBirth,  MemNum, MemAddress, MemTel, MemRegister, MemEmail, password, logname) ";
$sql .= "VALUES ";
$sql .= "('".$_POST["MemName"]."',";
$sql .= "'".$_POST["MemBirth"]."',";
$sql .= "'".$_POST["MemNum"]."',";
$sql .= "'".$_POST["MemAddress"]."',";
$sql .= "'".$_POST["MemTel"]."',";
$sql .= "now(),";
$sql .= "'".$_POST["Mememail"]."',";
$sql .= "'".$_POST["password"]."',";
$sql .= "'".$_POST["logname"]."')";

mysql_query("set NAMES tis620");
$sqlquery=mysql_db_query($dbname, $sql); 
$checkadd = "select * from member where logname = "."'".$_POST["logname"]."'";
$result = mysql_db_query($dbname, $checkadd);
$num=mysql_num_rows($result);
	  if ($num==1)
	  {
	  	print"<br>เพิ่มข้อมูลผู้ใช้ลงในฐานเรียนร้อยแล้ว";
		echo "<meta http-equiv=refresh content=1;URL=index.html>";
	  }elseif($num>=1)
	  		{
		  	print"<br>ชื่อผู้ใช้งานซ้ำกรุณาใช้ชื่ออื่น";
		  	}else
		  		{
		  		print"ระบบขัดข้อง";
		  		};
mysql_close();
  ?> 